package com.heaven.service;

import com.heaven.mapper.MapMapper;
import com.heaven.pojo.Maps;
import com.heaven.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class MapServiceImpl implements MapService{
    @Autowired
    private MapMapper mapMapper;
    @Override
    public PageResult addressList(PageResult pageResult) {
        int size=pageResult.getPageSize();
        int startNum=(pageResult.getPageNum()-1)*size;
        String query=pageResult.getQuery();

        List<Maps> rows=mapMapper.addressList(size,startNum,query);
        long total=mapMapper.findAddressList(query);
        pageResult.setRows(rows).setTotal(total);
        return pageResult;
    }

    @Override
    @Transactional
    public void deleteAddre(Integer id) {
        mapMapper.deleteAddre(id);
    }
}
